<?php
/* @var $this MemberController */
/* @var $model Member */

$this->breadcrumbs=array(
	'用户管理'=>array('admin'),
	'修改权限',
);
//设置页面标题
$this->pageTitle=Yii::app()->name.' - 修改权限';
$this->contentTitle='修改权限';
?>
<!--表单内容-->
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'Authitem_new-form',
	'enableAjaxValidation'=>false,
        'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>false
        ),
    'htmlOptions'=>array('class'=>'ajax_form','onsubmit'=>'return check()'),
)); ?>
<table cellspacing="1" class="myform">
	<tr>
		<td align="right" style="width:80px">权限名称</td>
		<td>
                    <?php echo $form->textField($model,'name',array('size'=>20,'maxlength'=>20,'class'=>'fl input')); ?>
                    <?php echo $form->error($model,'name'); ?>
		</td>
	</tr>

	<tr>
		<td align="right" style="width:80px">分配功能模块</td>
                <td><input type="checkbox" class="checkbox" onclick="select1();" />全选</td>
	</tr>
        <tr>
            <td align="right"></td>
            <td>
                <input id="ytAuthitem_new_checks1" type="hidden" value="" name="Authitem_new[checks1]">
                <span id="Authitem_new_checks1">
                    <?php echo $model_check1; ?>
            </td>
        </tr>
        
        <tr>
		<td align="right" style="width:80px">分配操作权限</td>
                <td><input type="checkbox" class="checkbox" onclick="select2();" />全选</td>
	</tr>
        <tr>
            <td align="right"></td>
            <td>
                <input id="ytAuthitem_new_checks2" type="hidden" value="" name="Authitem_new[checks2]">
                <span id="Authitem_new_checks2">
                    <?php echo $model_check2; ?>
            </td>
        </tr>
        

	<tr>
        <td align="right"></td>
        <td>
            <input class="but" type="submit" name="yt0" value="提 交" />
            <input class="but" type="button" name="yt1" onclick="back()" value="返 回" />        </td>
    </tr>
</table>
<?php $this->endWidget(); ?>
<script type="text/javascript">
    
    window.onload = function(){
        if(document.getElementById("Authitem_new_name")!=""){
            document.getElementById("Authitem_new_name").readOnly = true;
        }
    }
function check(){
    var a = document.getElementsByName("Authitem_new[checks1][]");
    var flag1=false;
    var flag2=false;
    for(var i = 0;i<a.length;i++){
        if(a[i].checked){
            flag1=true;
            break;
        }
    }
    
    var b = document.getElementsByName("Authitem_new[checks2][]");
    for(var i = 0;i<b.length;i++){
        if(b[i].checked){
            flag2=true;
            break;
        }
    }
    if(!flag1){
        alert("分配功能模块不能为空");
    }else if(!flag2){
        alert("分配操作权限不能为空");
    }
    
    if(flag1&&flag2){
        return true;
    }else{
        return false;
    }
}    
function back(){
    window.history.back(-1); 
}
function select1(){
        var a = document.getElementsByName("Authitem_new[checks1][]");
        if(a[0].checked){
            for(var i = 0;i<a.length;i++){
                if(a[i].type == "checkbox") a[i].checked = false;
            }
        }
        else{
            for(var i = 0;i<a.length;i++){
                if(a[i].type == "checkbox") a[i].checked = true;
            }
        }
}
function select2(){
        var a = document.getElementsByName("Authitem_new[checks2][]");
        if(a[0].checked){
            for(var i = 0;i<a.length;i++){
                if(a[i].type == "checkbox") a[i].checked = false;
            }
        }
        else{
            for(var i = 0;i<a.length;i++){
                if(a[i].type == "checkbox") a[i].checked = true;
            }
        }
}
</script>
